package com.yunhe.abnormal.client;

import com.yunhe.abnormal.client.fallback.MeasHistoryFallbackFactory;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.Measurement;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 量测历史数据Feign客户端
 * @author liuronglei
 */
@FeignClient(value = "ems-meas-history", fallbackFactory = MeasHistoryFallbackFactory.class)
@RequestMapping("/measurements")
public interface MeasHistoryClient {

    /**
     * 根据点号获得点号与最后一次值不同的前一次的值
     * @param pointNumber 点号
     */
    @RequestMapping(value = "/preValue", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Double>> getPreValue(@RequestParam("pointNumber") Long pointNumber);

    @RequestMapping(value = "/preValue/byTime", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Double>> getPreValue(@RequestParam("pointNumber") Long pointNumber,
                                                     @RequestParam("dtime") String dtime);

    @RequestMapping(value = "/nextValue/byTime", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Measurement>> getNextMeasurement(@RequestParam("pointNumber") Long pointNumber,
                                                            @RequestParam("dtime") String dtime);

    @RequestMapping(value = "/batch", method = RequestMethod.POST)
    ResponseEntity<ResultObject> createMeasurementAsync(@RequestBody DomainList<Measurement> measurements,
                                                        @RequestParam("frequency") String frequency);
}
